
#ifndef NODE_H
#define	NODE_H

#include <systemc>
#include <map>
#include <string>

#include "packet_types.h"
#include "network_channel.h"

class network_node 
: public sc_core::sc_module      
{      
public:    
            
    network_node(const sc_core::sc_module_name &name, 
                  packet::mac_address node_addr);
    virtual ~network_node();
            
    sc_core::sc_port<channel_read_if> in;
    sc_core::sc_port<channel_write_if> out;
    
    static packet::mac_address next_address();
                        
protected:    
               
    virtual void send();    
    virtual void receive();    
    virtual void repeat();
    virtual void release_token();
    
    // случайные данные для отправки
    virtual bool is_recv_data_ready();      
    virtual frame *generate_random_frame(const token& tkn);                    
        
    sc_core::sc_event m_token_seize_evt;   
    sc_core::sc_event m_packet_repeat_evt;
    sc_core::sc_event m_token_release_evt;
    
    packet::mac_address m_node_addr;    
    packet *m_read_buf;

    frame *m_send_frame;
    bool m_transmition_ok;
    
    static std::vector<packet::mac_address> m_address_table;
    static std::map<packet::mac_address, std::string> m_address_map;
};

#endif	/* NODE_H */

